﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CXMLStudioIDE.Common;
using CXMLStudioIDE.Common.Entities;
using CXMLStudioIDE;
using System.Data;

namespace CXMLStudioIDE.Common.Entities
{
    public partial class Project : Entity
    {
        #region Declarations

        private string _ProjectOwnerID;
        private bool _defaultProject;
        private DateTime _lastOpened;
        private Scope _Scope;
        private Context _Context;
        private BusinessEntityCollection _Entities;
        private int _TreeViewID;

        #endregion Declarations

        #region Constructors

        public Project()
        {
            _Context = new Context();
            _Scope = new Scope();
            _Entities = new BusinessEntityCollection();
        }
        #endregion

        #region Public Properties
        public int TreeViewID
        {
            get { return _TreeViewID; }
            set { _TreeViewID = value; }
        }
        public Scope Scope
        {
            get { return _Scope; }
            set { _Scope = value; }
        }

        public Context Context
        {
            get { return _Context; }
            set { _Context = value; }
        }

        public BusinessEntityCollection Entities
        {
            get { return _Entities; }
            set { _Entities = value; }
        }

        public string ProjectOwnerID
        {
            get { return _ProjectOwnerID; }
            set { _ProjectOwnerID = value; }
        }

        public bool DefaultProject
        {
            get { return _defaultProject; }
            set { _defaultProject = value; }
        }

        public DateTime LastOpened
        {
            get { return _lastOpened; }
            set { _lastOpened = value; }
        }

        #endregion

        #region Methods

        public BusinessEntity GetBusinessEntityByTreeViewID(int _TreeViewID)
        {
            foreach (BusinessEntity b in this.Entities)
            {
                if (b.TreeViewId == _TreeViewID)
                    return b;
            }
            return null;
        }

        public void RemoveBusinessEntity(BusinessEntity b)
        {
            _Entities.Remove(b);
        }

        #endregion

    }
}
